package fangzhiyi_day0321.diary;

import java.util.ArrayList;
import java.util.Scanner;

/**
 * @author fangzhiyi
 * @version 1.0
 * @date 2025/3/21 14:12
 * @description
 */
public class DiaryTest {
  static   Scanner input = new Scanner(System.in);
  static   ArrayList<Student> list = new ArrayList<Student>();
  static   ArrayList<Diary> diaries = new ArrayList<Diary>();

    public static void main(String[] args) {

        while (true){
            System.out.println("---------------------------------------------------------------------");
            System.out.println("1.学生添加");
            System.out.println("2.学生登录");
            System.out.println("3.日志提交");
            System.out.println("4.查看当前登陆人提交的所有日志");
            System.out.println("5.修改当前登陆人提交的日志内容");
            System.out.println("6.退出登录");
            System.out.println("---------------------------------------------------------------------");
            System.out.print("请输入你的选择:");
            int num = input.nextInt();
            switch (num){
                case 1://学生添加
                    add();
                    break;
                case 2://学生登录
                    login();
                    break;
                case 3://日志提交
                    tabled();
                    break;
                case 4://查看当前登录人提交的所有日志
                    findTabled();
                    break;
                case 5://修改当前登陆人提交的日志内容
                    break;
                default://退出登录
                    System.exit(0);
            }


        }
    }
    public static void init(){
        list.add(new Student(123,"南风","123"));
        list.add(new Student(456,"知我意","123"));
        list.add(new Student(789,"桐桐","123"));
        System.out.println(list);
    }

    public static void initDiary(){
        diaries.add(new Diary(1,"java","一般","关于static的使用","南风"));
        diaries.add(new Diary(2,"java","良好","关于final的使用","南风"));
        diaries.add(new Diary(3,"java","一般","关于ArrayList的使用","南风"));
        diaries.add(new Diary(4,"java","良好","关于南风能不能知我意的问题","南风"));
    }
        public static void add(){
            System.out.println("请输入学号");
            int xueHao = input.nextInt();
            System.out.println("请输入姓名");
            String name = input.next();
            System.out.println("请输入密码");
            String miMa = input.next();
            list.add(new Student(xueHao,name,miMa));

            System.out.println(list);
            init();
        }

      public static void login(){
        init();

          System.out.println("请输入账号");
        String name = input.next();
          System.out.println("请输入密码");
          String password = input.next();

          for (int i = 0; i < list.size(); i++) {

              if (name.equals(list.get(i).getName())){
                  if (password.equals(list.get(i).getPassword())){
                      System.out.println("登录成功");
                      return;
                  }else {
                      System.out.println("您输入的账号或密码有误");
                      return;
                  }

              }else {
                  System.out.println("您输入的账号密码有误");
                  return;
              }

          }

      }

      public static void tabled(){
          initDiary();
        int number = diaries.size()-1;
          System.out.println("今日学习内容");
          String part = input.next();
          System.out.println("掌握程度");
          String grasps = input.next();
          System.out.println("疑问");
          String doubt = input.next();
          System.out.println("学生名称");
          String name = input.next();

          diaries.add(new Diary(number++,part,grasps,doubt,name));
          System.out.println(diaries);


      }
      public static void findTabled(){

          System.out.println("请输入当前登录人的姓名");
          String name = input.next();
          for (int i = 0; i < diaries.size(); i++) {
              if (name.equals(diaries.get(i).getName())){
                  System.out.println(diaries.get(i));
              }
          }
      }


}
